<style type="text/css">
a{
text-decoration: none;
}
</style>
<script type="text/javascript">
function checkPost(){
	if($("#postContent").val().length <5){
		alert("回复不得少于5个字");
		return false;
	}
}
function checkPage(){
	if($("#slider").val().length <1){
		alert("请输入想转去的页码");
		return false;
	}
}

</script>
<script type="text/javascript">
    <!--
    function setFocus(){
        document.replyform.postContent.focus();
        document.replyform.postContent.innerHTML='';
    }
    -->
</script>
<script type="text/javascript">
<!--
var deletePath = "<?php echo CController::createUrl('user/removefavorite')?>";
function removeFavorite(obj,id){
	$(obj).parent().remove();
	window.path1=deletePath+"/id/"+id;
	$.ajax({
		url:deletePath+"/id/"+id
	});
}
//-->
</script>

<!-- Start of first page -->
<div data-role="page" data-fullscreen="true">
		<div class="content-primary">
			<div class="ui-body ui-body-b" style="padding:0 0 0 0;">
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer" style="width:40%;padding:0 0 0 0;"">
						<?php echo CHtml::link("$bbs->title",array("bbs/list","id"=>"$bbs->id"),array("data-role"=>"button","data-icon"=>"back"))?>
					</div>
					<div class="ui-block-b tie-footer" style ="width:30%;padding:0 0 0 0;"">
						<?php if($pages->pageCount>1):?>
							<a data-role="button"  data-icon="search" data-transition="pop" data-rel="dialog" href="#topage">换页</a>
						<?php endif?>
					</div>
					<div class="ui-block-c tie-footer" style ="width:30%;padding:0 0 0 0;"">
						<a data-role="button" data-icon="arrow-d" href="#" onclick="javascript:setFocus()">回复</a>
					</div>
				</div>
			</div>
			<div class="ui-body ui-body-c tie-top-ads" style="text-align: center;">
				广告
			</div>
		
			<div class="ui-body ui-body-d tie-body">
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer" style="width:70%;padding-left:0px;">【<?php echo $topic->category?>】<?php echo $topic->title;?></div>
					<div class="ui-block-b tie-footer" style ="width:30%;text-align:right;">
					<?php if(empty($see_lz)):?>
						<a style="text-decoration: none;" rel='external' href="<?php echo Yii::app()->createUrl('bbs/view', array('id'=>$topic->id,'see_lz'=>"1")); ?> ">只看楼主</a>
					<?php else:?>
						<a style="text-decoration: none;" rel='external' href="<?php echo Yii::app()->createUrl('bbs/view', array('id'=>$topic->id)); ?> ">取消只看楼主</a>
					<?php endif?>
					</div>
				</div>
			</div>		
			<?php $thisPage = $pages->currentPage;?>
			<?php $n= $thisPage*20;?>
			<?php foreach($posts as $post):?>
			<?php $n++;?>
			<?php if($post->flag =='active'):?>
			<div class="ui-body ui-body-d tie-body">
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer"><?php echo $n?>楼</div>
					<div class="ui-block-b tie-footer" style ="text-align:right;">
						<a style="text-decoration: none;" rel='external' href="<?php echo Yii::app()->createUrl('bbs/reply', array('id'=>$topic->id,'title'=>"回复:".$n."楼 ".$post->author)); ?> ">	回复本楼</a>
					</div>
				</div><!-- /grid-a -->
				<?php if(!empty($post->title)):?>	
				<div class="tie-title">
					<?php echo $post->title?>
				</div>
				<?php endif?>
				<?php if(Utils::checkMobile()==0):?>
				<div class='tie-body-content'>
					<?php echo $content=nl2br($post->content);?>
				</div>
				<?php else:?>
				<div class='tie-body-mobile'>
					<?php echo $content=nl2br($post->content);?>
				</div>
				<?php endif?>
				<div class="ui-grid-a">
					<div class="ui-block-a tie-footer">作者:
						<?php if(!empty($post->member_id)):?>
						<a style="text-decoration: none;color:#0B3861" rel='external' href="<?php echo Yii::app()->createUrl('bbs/user', array('id'=>$post->member_id));?> "><?php echo $post->author;?></a>
						<?php else:?>
						<?php echo
						substr($post->author, 0, strripos($post->author,'.') ).".***"?>
						<?php endif?>
					</div>
					<div class="ui-block-b tie-footer" style ="text-align:right"><?php echo mb_substr($post->created,0,16,"UTF-8");?></div>
				</div><!-- /grid-a -->			
			</div><!-- /themed container -->
			<?php endif?>
			<?php endforeach?>

			<?php if($pages->pageCount>1):?>
					<div data-role="controlgroup" data-type="horizontal" style="margin-left:10px;">
					<?php
					$currentPage = $pages->currentPage+1;
					for($i=1;$i<=$pages->pageCount;$i++){
						if($i==$currentPage){
							echo CHtml::link($i,array("","id"=>$topic->id,"page"=>$i,"see_lz"=>$see_lz), array("data-role"=>"button","data-theme"=>'b','rel'=>'external'));
						}else{
							echo CHtml::link($i,array("","id"=>$topic->id,"page"=>$i,"see_lz"=>$see_lz), array("data-role"=>"button",'rel'=>'external'));
						}
					}?>
					</div>
			<?php endif?>
		</div>
		
		<div style="margin:5px 5px 5px 5px;">
		<?php echo CHtml::form('','post',array("onsubmit"=>"return checkPost();","enctype"=>"multipart/form-data","data-ajax"=>"false","name"=>"replyform")); ?>
			<input type="hidden" name="BbsPost[topic_id]"
				value="<?php echo $topic->id;?>" />
			<textarea style='width: 95%; height: 100px;' name="BbsPost[content]"
				id='postContent' onclick="this.innerHTML=''"
				>回复。。</textarea>
			<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />
			<?php if(!yii::app()->user->isGuest  && UserIdentity::getFlag(Yii::app()->user->id) =="admin"):?>
			<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />
			<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />
			<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />
			<input type='file'class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c"name="image[]"> <br />
			<?php endif?>
			<input type='submit' data-theme='b' value='回复' data-inline='true'/>
		<?php echo CHtml::endForm(); ?>
		</div>
		
		<!--/content-primary -->
	<div data-role="footer" data-position="fixed">
		<div data-role="navbar" data-theme="e">
		<?php $currentPage = $pages->currentPage+1;?>
			<ul>
				<li><?php echo CHtml::link("论坛",array("bbs/list"),array("data-icon"=>"home","data-theme"=>"b","rel"=>"external"))?>
				</li>
				<li><a data-theme="b" data-icon="star" data-rel='dialog' data-transition='pop' href="<?php echo CController::createUrl("user/favorite",array("id"=>$topic->id,"page"=>$currentPage,"title"=>$topic->title))?>">收藏</a>
				</li>
				<li><?php echo CHtml::link("用户",array("bbs/user"),array("data-icon"=>"gear","data-theme"=>"b","rel"=>"external"))?>
				</li>
				<?php if ($currentPage != 1):?>
				<li><?php echo CHtml::link("上页",array("bbs/view","id"=>$topic->id,"page"=>$currentPage-1,"see_lz"=>$see_lz),array("data-icon"=>"arrow-l","data-theme"=>"b"))?>
				</li>
				<?php endif?>
				<?php if ($currentPage != $pages->pageCount):?>
				<li><?php echo CHtml::link("下页",array("bbs/view","id"=>$topic->id,"page"=>$currentPage+1,"see_lz"=>$see_lz),array("data-icon"=>"arrow-r","data-theme"=>"b"))?>
				</li>
				<?php endif?>
			</ul>
		</div>
		<!-- /navbar -->
	</div>
		<!-- /footer -->
	
		
		<?php $this->renderPartial("//site/footer")?>
		<!-- /footer -->
</div>
<!-- /page -->


<div data-role="page" id="topage">
	<div data-role="header" data-theme="b">
		<h1>
			转到指定页面
		</h1>
	</div>
	<div data-role="content" style="padding: 0 0 0 0;background-color:white;">
		<div class="ui-body ui-body-b">
		<?php echo CHtml::form('','get',array("onsubmit"=>"return checkPage();","data-ajax"=>"false","name"=>"redirectform")); ?>
			<input type =hidden name="id" value="<?php echo $topic->id?>"/>
			<input type =hidden name="see_lz" value="<?php echo $see_lz?>"/>
			<div data-role="fieldcontain">
				<label for="slider">拖动滑块或直接输入想去的页面:</label>
			 	<input type="range" name="page" id="slider" value="<?php echo $currentPage ?>" min="1" max="<?php echo $pages->pageCount;?>"  />
			</div>
			<input type='submit' data-theme='b' value='确定' data-inline='true'/>
		<?php echo CHtml::endForm(); ?>
		</div>
	</div>
	<?php $this->renderPartial("//site/footer")?>
	<!-- footer -->	
</div>
<!-- /page -->
